<?php


namespace Modules\Common\Util;


use Illuminate\Support\Carbon;

class Time
{
    public static function format($timeString)
    {
        return date('Y-m-d H:i:s', strtotime($timeString));
    }


    public static function hoursPassed($startTime, $endTime)
    {
        $startDay = Carbon::createFromFormat('Y-m-d H:i:s', $startTime);
        $endDay = Carbon::createFromFormat('Y-m-d H:i:s', $endTime);

        return $startDay->diffInHours($endDay);
    }

    public static function yearsPassed($startTime, $endTime)
    {
        $startDay = Carbon::createFromFormat('Y-m-d', $startTime);
        $endDay = Carbon::createFromFormat('Y-m-d', $endTime);

        return $startDay->diffInYears($endDay);
    }

}
